<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include.inc.jsp"%>
<div class="pageContent">
	<form method="post" action='<c:url value="/system/user/assignmenu"/>' class="pageForm required-validate" onsubmit="return validateCallback(this , dialogAjaxDone)">
		<div class="pageFormContent" layoutH="57">
			<ul class="tree treeFolder treeCheck expand" oncheck="checkMenu">
				<li> <a href="javascript:">全选</a>
					<ul>
						<c:forEach items="${menus }" var="menu">
							<li>
								<a href="javascript:" tname="menuIds" tvalue="${ menu.id}" 
									<c:forEach items="${hasMenus}" var="hm">
										<c:if test="${hm.id eq menu.id}">
											checked="true"
										</c:if>
									</c:forEach>
								>${menu.name}</a>
							</li>
						</c:forEach>
					</ul>
				</li>
			</ul>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div> 
		<input type="hidden" value="${param.userId }" name="userId">
		<input type="hidden" name="callbackType" value="closeCurrent"> 
		<input type="hidden" name="navTabId" value="tab_system_user_list"> 
		<input type="hidden" name="rel" value="dialog_system_user_authorize">
	</form>
</div>
<script>
	function checkMenu(data){
			console.debug($.type(data.items) != 'array');
		if($.type(data.items) != 'array'){
			console.debug($("input[name='" + data.items.name +"'][value='" + data.items.value + "']"));
			if(data.checked){
				$("input[name='" + data.items.name +"'][value='" + data.items.value + "']").attr("checked","checked");
			}else{
				$("input[name='" + data.items.name +"'][value='" + data.items.value + "']").attr("checked","");
			}
		}	
	}
	
</script>